<template>
  <div class="row">
      <div v-show="info.users.length" class="card"  v-for="user in info.users" :key="user.id">
        <a :href="user.html_url" target="_blank">
          <img :src="user.avatar_url" style='width: 100px'/>
        </a>
        <p class="card-text">{{user.login}}</p>
      </div>
      <!-- 展示欢迎词 -->
      <h1 v-show="info.isFirst">Welcome to Using</h1>
      <!-- 展示加载中 -->
      <h1 v-show="info.isLoading">Loading</h1>
      <!-- 显示错误信息 -->
      <h1 v-show="info.errMsg">{{info.errMsg}}</h1>
    </div>
</template>

<script>
export default {
    name:'List',
    data() {
        return {
            info:{
                isFirst:true,
                isLoading:false,
                errMessage:'',
                users:[]
            }
        }
    },
    mounted(){
        this.$bus.$on('updateUsers',(dataObj)=>{
            this.info = {...this.info,...dataObj}
        })
    }
}
</script>

<style>

</style>